﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Collections.ObjectModel;
using SharpMap.Rendering.Rendering2D;
using System.ComponentModel;

namespace SharpMap.Presentation.Wpf
{
    public class MapLayerViewModel :  ObservableCollection<Drawing>
    {
        MapViewModel _mapViewModel;
        internal MapViewModel MapViewModel
        {
            get { return _mapViewModel; }
            set 
            { 
                _mapViewModel = value;
                if (_mapViewModel != null)
                {
                    _mapViewModel.PropertyChanged += new PropertyChangedEventHandler(mapViewModelPropertyChanged);
                }
            }
        }

        void mapViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "ToViewTransform")
            {
                OnPropertyChanged(e);
            }
        }

 


        public MapLayerViewModel(MapViewModel mapModel)
        {
            MapViewModel = mapModel;
        }

        public Matrix2D ToViewTransform
        {
            get
            {
                if (_mapViewModel != null)
                {
                    return _mapViewModel.ToViewTransform;
                }
                else
                {
                    return Matrix2D.Identity;
                }
            }
         }
     }
}
